﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BUS;
using DTO;

namespace DentalSoftware
{
    public partial class TimBenhNhan : Form
    {
        private BenhNhanForm bnf;
        private DieuTriForm dtf;
        public TimBenhNhan(Form form, int loai)
        {
            InitializeComponent();
            if (loai == 1)
                bnf = (BenhNhanForm)form;
            else
                dtf = (DieuTriForm)form;
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.No;
            this.Close();
        }

        private void btnTim_Click(object sender, EventArgs e)
        {
            BenhNhanDTO bn = new BenhNhanDTO();
            if (!txtMa.Text.Equals(""))
                bn.Ma = int.Parse(txtMa.Text);
            bn.Hoten = txtHoTen.Text;
            if (rbnNam.Checked)
                bn.Gioitinh = 0;
            if (rbnNu.Checked)
                bn.Gioitinh = 1;
            if (!txtTuoi.Text.Equals(""))
                bn.Ngaysinh = new DateTime(DateTime.Now.Year - int.Parse(txtTuoi.Text), 1, 1);

            if (bnf != null)
            {
                bnf.kqtimBN = bn;
            }
            else
            {
                dtf.kqtimBN = bn;
            }
            this.DialogResult = DialogResult.Yes;
            this.Close();
        }       
    }
}
